//
//  LoginAPI.swift
//

import Alamofire

extension Network {
    enum Login {
        /// 获取验证码
        ///
        /// - Parameters:
        ///   - mobile: 用户登录手机号
        case getCode(mobile: String)
        /// 账号密码登录
        ///
        /// - Parameters:
        ///   - mobile: 账号
        ///   - smsCode: 密码
        case login(userAccount: String, password: String)
    }
}

extension Network.Login: TargetType {
    
    var baseURL: String {
        return NetworkEnvironment.login.baseURL
    }
    
    var path: String {
        switch self {
        case .getCode:
            return "verify/sms3"
        case .login:
            return "user/loginWithPhoneV2"
        }
    }
    
    var parameters: [String: Any] {
        switch self {
        case let .getCode(mobile):
            return ["phone": mobile]
        case let .login(mobile, smsCode):
            return ["srcApp": "com.ubestkid.collection",
                    "deviceId": "8039a09a9a56f2cb8cb51b956c2",
                    "phone": mobile,
                    "smsCode": smsCode]
        }
    }
}
